#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
ll n, m, l, s;
ll d[N], v[N], a[N], p[N], cnt1, vis[N];
int ans;
vector<int> c;
void solve(int k) {
    int sz = c.size();
    if (sz >= ans) return;
    if (k > m) {
        int cnt = 0;
        for (int i = 1; i <= n; i++) vis[i] = 0;
        for (int i : c) {
            for (int j = 1; j <= n; j++) {
                if (d[j] <= p[i]) {
                    ll aa = s * s, bb = 2 * a[j] * (p[i] - d[j]) + v[j] * v[j];
                    if (aa < bb) vis[j] = 1;
                }
            }
        }
        for (int i = 1; i <= n; i++) if (vis[i]) cnt++;
        if (cnt == cnt1) ans = sz;
        return;
    }
    solve(k + 1);
    c.push_back(k);
    solve(k + 1);
    c.pop_back();
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    cin >> T;
    while (T--) {
        cin >> n >> m >> l >> s;
        bool st1 = 1, st2 = 1;
        for (int i = 1; i <= n; i++) {
            cin >> d[i] >> v[i] >> a[i];
            if (a[i] != 0) st1 = 0;
            if (a[i] <= 0) st2 = 0;
        }
        for (int i = 1; i <= m; i++) {
            cin >> p[i];
        }
        sort(p + 1, p + m + 1);
        if (st1 || st2) {
            int cnt = 0;
            for (int i = 1; i <= n; i++) {
                if (d[i] <= p[m]) {
                    ll aa = s * s, bb = 2 * a[i] * (p[m] - d[i]) + v[i] * v[i];
                    if (aa < bb) cnt++;
                }
            }
            if (cnt == 0) cout << cnt << ' ' << m << endl;
            else cout << cnt << ' ' << m - 1 << endl;
            continue;
        }
        if (n <= 20 && m <= 20) {
            for (int i = 1; i <= n; i++) vis[i] = 0;
            for (int i = 1; i <= m; i++) {
                for (int j = 1; j <= n; j++) {
                    if (d[j] <= p[i]) {
                        ll aa = s * s, bb = 2 * a[j] * (p[i] - d[j]) + v[j] * v[j];
                        if (aa < bb) vis[j] = 1;
                    }
                }
            }
            cnt1 = 0, ans = N;
            for (int i = 1; i <= n; i++) if (vis[i]) cnt1++;
            cout << cnt1 << ' ';
            solve(1);
            cout << m - ans << endl;
        } else {
            cout << 0 << ' ' << 0 << endl;
        }
    }
    return 0;
}
//2e9
